package com.pos.app.config;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 右边控件操作类
 * 
 * @author oyj
 * 
 */
public class CustomOperateName
{

	public static final int I_DELETE = 994;// 删除
	public static final int I_SAVE = 995;// 保存
	public static final int I_CLEAR = 996;// 清空
	public static final int I_SEARCH = 997;// 搜索
	public static final int I_REFRESH = 998;// 刷新
	public static final int I_REBACK = 999;// 返回


	public enum EmunOperateName
	{
		DELETE(I_DELETE, "删除"), 
		SAVE(I_SAVE, "保存"), 
		CLEAR(I_CLEAR, "清空"), 
		REFRESH(I_REFRESH, "刷新"), 
		SEARCH(I_SEARCH, "搜索"), 
		REBACK(I_REBACK, "返回");

		private int id;
		private String name;

		private EmunOperateName(int id, String name)
		{
			this.id = id;
			this.name = name;
		}

		public static String getName(int id)
		{
			for (EmunOperateName c : values())
			{
				if (c.getId() == id)
				{
					return c.name;
				}
			}
			return null;
		}

		public String getName()
		{
			return name;
		}

		public void setName(String name)
		{
			this.name = name;
		}

		public int getId()
		{
			return id;
		}

		public void setId(int id)
		{
			this.id = id;
		}
	}

	// 右边ListView操作
	public static List<Map<String, Object>> getOperate(List<EmunOperateName> operateName)
	{
		List<Map<String, Object>> listMenu = new ArrayList<Map<String, Object>>();
		// 构造右边List操作
		if (operateName != null)
		{
			for (int i = 0; i < operateName.size(); i++)
			{
				EmunOperateName eon = operateName.get(i);
				Map<String, Object> mapMenu = null;
				mapMenu = new HashMap<String, Object>();
				mapMenu.put("id", eon.getId());
				mapMenu.put("name", eon.getName());
				listMenu.add(mapMenu);
			}
		}
		return listMenu;
	}
}
